linedisplay: Save paragraph bg color inline
authorTimm Bäder <mail@baedert.org>
Sun, 21 Jul 2019 07:47:09 +0000 (09:47 +0200)
committerTimm Bäder <mail@baedert.org>
Sun, 21 Jul 2019 07:47:09 +0000 (09:47 +0200)
No need to allocate this separately.

gtk/gtktextdisplay.c
gtk/gtktextlayout.c
gtk/gtktextlayoutprivate.h

index de02bd3b474320a143611cef42e8af9b369a1698..9c2dae9e14a32f0c615bfabeef098e10baa8cdba 100644 (file)
@@ -642,13 +642,13 @@ render_para (GtkTextRenderer    *text_renderer,
         }
       else
         {
-          if (line_display->pg_bg_rgba)
+          if (line_display->pg_bg_rgba_set)
             {
               cairo_t *cr = text_renderer->cr;
 
               cairo_save (cr);
  
-             gdk_cairo_set_source_rgba (text_renderer->cr, line_display->pg_bg_rgba);
+              gdk_cairo_set_source_rgba (text_renderer->cr, &line_display->pg_bg_rgba);
               cairo_rectangle (cr, 
                                line_display->left_margin, selection_y,
                                screen_width, selection_height);
index f941e331156cc46aa518023110a2933306ea0410..79785773d1e4c66797f50b1679efabe7a96ecdc9 100644 (file)
@@ -1431,11 +1431,16 @@ set_para_values (GtkTextLayout      *layout,
       pango_layout_set_wrap (display->layout, pango_wrap);
     }
   display->total_width = MAX (layout->screen_width, layout->width) - h_margin - h_padding;
-  
+
   if (style->pg_bg_rgba)
-    display->pg_bg_rgba = gdk_rgba_copy (style->pg_bg_rgba);
+    {
+      display->pg_bg_rgba = *style->pg_bg_rgba;
+      display->pg_bg_rgba_set = TRUE;
+    }
   else
-    display->pg_bg_rgba = NULL;
+    {
+      display->pg_bg_rgba_set = FALSE;
+    }
 }
 
 static PangoAttribute *
@@ -2630,9 +2635,6 @@ gtk_text_layout_free_line_display (GtkTextLayout      *layout,
       if (display->cursors)
         g_array_free (display->cursors, TRUE);
 
-      if (display->pg_bg_rgba)
-        gdk_rgba_free (display->pg_bg_rgba);
-
       g_slice_free (GtkTextLineDisplay, display);
     }
 }
index 8f0b1895d9a9c52638128dbac2885a721c433caf..8af8465349701b6ed925344c90c1752fafb4faa9 100644 (file)
@@ -246,7 +246,8 @@ struct _GtkTextLineDisplay
   guint cursor_at_line_end : 1;
   guint size_only : 1;
 
-  GdkRGBA *pg_bg_rgba;
+  GdkRGBA pg_bg_rgba;
+  guint pg_bg_rgba_set : 1;
 };
 
 #ifdef GTK_COMPILATION